﻿#ifndef CONFIG_H
#define CONFIG_H
#include <QDebug>
#include <QWaitCondition>
#include <QMutex>
extern "C"{
    #include "ffmpeg/include/libavcodec/avcodec.h"
    #include "ffmpeg/include/libavformat/avformat.h"
    #include "ffmpeg/include/libavfilter/avfilter.h"
    #include "ffmpeg/include/libswscale/swscale.h"
    #include "ffmpeg/include/libavutil/frame.h"
    #include "ffmpeg/include/libavutil/mem.h"
    #include "ffmpeg/include/libavutil/hwcontext_vaapi.h"
    #include "ffmpeg/include/libavutil/hwcontext.h"
    #include "ffmpeg/include/libavutil/imgutils.h"

    #include "sdl2/include/SDL.h"
    #include "sdl2/include/SDL_video.h"
    #include "sdl2/include/SDL_render.h"
    #include "sdl2/include/SDL_rect.h"
    #include "sdl2/include/SDL_bits.h"
    #include "sdl2/include/SDL_thread.h"
    #include "sdl2/include/SDL_events.h"
}
#undef main

#define PRTLOG()    qDebug()<<__FILE__<<__FUNCTION__<<"Line:"<<__LINE__<<":"

enum DeviceType{
    Device_Analog=0,
    Device_IP=1
};                                              //设备类型是选择IP模式还是模拟模式 0 --模拟  1---IP
enum StreamProtocolType{
    StreamProtocol_AUTO=0,
    StreamProtocol_TCP=1,
    StreamProtocol_UDP=2,
    StreamProtocol_RTP=3
};                                              //设备使用的拉流协议类型
enum CommandProtocolType{
    CommandProtocol_HISOME=0,
    CommandProtocol_ONVIF=1,
    CommandProtocol_UNKNOWN=2
};                                              //设备使用的通信协商协议类型
enum IsOnline{
    IsOnline_OFF=0,
    IsOnline_ON=1,
    IsOnline_READY=2
};                                              //设备是否在线标志
enum GetStream{
   GetStream_FAIL=0,
   GetStream_OK=1
};                                              //设备是否拉流成功
enum HisomeType{
   Hisome_368=0,
   Hisome_385=1,
   Hisome_3516=2,
   Hisome_unknown=3
};                                              ///HISOME内部型号区分----add by Gaoy---20180228



typedef struct _deviceinfo{
   int  ChannelID;                              //设备的通道号

   DeviceType Device_type;                      //设备通道类型 0---模拟  1-----IP
   HisomeType Hisome_type;                      ///HISOME内部型号区分----add by Gaoy---20180228
   QString IPAddr;                              //设备IP地址
   CommandProtocolType Command_protocol_Type;   //协商通信协议
   int Port;                                    //端口----在onvif的时候有用，HECP无用
   QString User_Name;                           //访问设备所采用的用户名
   QString User_Passwd;                         //访问设备所采用的用户密码
   StreamProtocolType Stream_protocol_Type;     //流发送协议类型
   QString ChannelName;                         //通道名称
   IsOnline Isonline;                           //判断IPC是否与NVR/DVR连接上
   bool TimeState;                              //时间状态-----add by Gaoy--20171208
   bool AlarmState;                             //报警状态-----add by Gaoy--20171208
   GetStream Getstream;                         //NVR/DVR是否成功拉到了IPC的流------待确定是否需要

   QString ONVIF_MediaXaddr;
   QString ONVIF_DeviceXaddr;
   QString ONVIF_EventXaddr;
   QString ONVIF_ImageXaddr;
   QString ONVIF_AnalyticsXaddr;
   QString ONVIF_OSD0Token;
   bool    StreamPlayStatus;
}deviceInfo;									//远程设备结构


typedef struct __HSPlayer_WindowRect{
    int pos_x;
    int pos_y;
    int width;
    int height;
}HSPlayer_WindowRect;


typedef enum __HSPlayer_PlayStatus{
 HSPlayer_Play =0,
 HSPlayer_Pause=1,
 HSPlayer_Stop =2
}HSPlayer_PlayStatus;







typedef enum _HS_StreamType{
  HS_STREAMING=0,
  HS_RECORDING=1
}StreamType;

extern enum AVPixelFormat HS_Video_HWPix_fmt;
void sleep_ms(unsigned long ms);
enum AVPixelFormat get_hw_format(AVCodecContext *ctx,const enum AVPixelFormat *pix_fmts);
#endif // CONFIG_H
